package com.itxx.keyCase;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

//新版本日期的转换[3]
public class NewDateDemo2 {
    public static void main(String[] args) {

        //将LocalDateTime转换为String
        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String format = localDateTime.format(pattern);
        System.out.println(format);
        //将String转换为LocalDateTime
        String s = "2020-11-11 12:12:12";
        LocalDateTime parse = LocalDateTime.parse(s, pattern);
        System.out.println(parse);
    }
}
